package com.shuai.chatroom.controller;

import cn.hutool.extra.servlet.ServletUtil;
import com.shuai.chatroom.common.HttpResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;

@RestController
@RequestMapping("/files")
public class FileDownLoadController {


    @Value("${up_file_path}")
    private String filePath;

    /**
     * 处理文件下载的请求
     */
    @RequestMapping("/down")
    public void downLoadFile(String filename, HttpServletResponse response) {
        ServletUtil.write(response, new File(filePath + filename));
    }
}
